<script setup lang="ts">

let contentToBeSend = ref("");
let ws: WebSocket | null;

function sendMessage() {
  ws?.send(contentToBeSend.value);
}

onMounted(() => {
  ws = new WebSocket("ws://localhost:8080/");
  ws.onmessage = (msg: MessageEvent) => {
    console.log('Received message', msg);
  }
})
</script>

<template>
  <v-container>
    <v-row>
      <v-col>
        会话展示区
      </v-col>
    </v-row>
    <v-row>
      <v-col>
        <v-textarea v-model="contentToBeSend"/>
      </v-col>
      <v-col>
        <v-btn :disabled="contentToBeSend.length ==0 || ws === null" @click="sendMessage">发送</v-btn>
      </v-col>
    </v-row>
  </v-container>
</template>

<style scoped>

</style>